home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / addhead.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  84 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addhead.c,v 1.5 1996/08/13 13:55:55 digulla Exp $
  4.     $Log: addhead.c,v $
  5.     Revision 1.5  1996/08/13 13:55:55  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.4  1996/08/01 17:41:01  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17.  
  18. /*****************************************************************************
  19.  
  20.     NAME */
  21.     #include <exec/lists.h>
  22.     #include <clib/exec_protos.h>
  23.  
  24.     __AROS_LH2I(void, AddHead,
  25.  
  26. /*  SYNOPSIS */
  27.     __AROS_LHA(struct List *, list, A0),
  28.     __AROS_LHA(struct Node *, node, A1),
  29.  
  30. /*  LOCATION */
  31.     struct SysBase *, SysBase, 40, Exec)
  32.  
  33. /*  FUNCTION
  34.     Insert Node node as the first node of the list.
  35.  
  36.     INPUTS
  37.     list - The list to insert the node into
  38.     node - This node is to be inserted
  39.  
  40.     RESULT
  41.  
  42.     NOTES
  43.  
  44.     EXAMPLE
  45.     struct List * list;
  46.     struct Node * pred;
  47.  
  48.     // Insert Node at top
  49.     AddHead (list, node);
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.  
  55.     INTERNALS
  56.  
  57.     HISTORY
  58.     26-08-95    digulla created after EXEC-Routine
  59.     26-10-95    digulla adjusted to new calling scheme
  60.  
  61. ******************************************************************************/
  62. {
  63.     __AROS_FUNC_INIT
  64.     assert (node);
  65.     assert (list);
  66.  
  67.     /*
  68.     Make the node point to the old first node in the list and to the
  69.     head of the list.
  70.     */
  71.     node->ln_Succ       = list->lh_Head;
  72.     node->ln_Pred       = (struct Node *)&list->lh_Head;
  73.  
  74.     /*
  75.     New we come before the old first node which must now point to us
  76.     and the same applies to the pointer to-the-first-node in the
  77.     head of the list.
  78.     */
  79.     list->lh_Head->ln_Pred = node;
  80.     list->lh_Head       = node;
  81.     __AROS_FUNC_EXIT
  82. } /* AddHead */
  83.  
  84.